import { Button, List, WhiteSpace, WingBlank } from 'antd-mobile';
import React, { Component } from 'react';
import { View, StyleSheet, ScrollView, Image, FlatList, Text } from 'react-native';
import { Urls } from '../../utils/Urls';
const Item = List.Item;
export class SubStationListScreen extends Component {
    static navigationOptions = {
        tabBarLabel: '数据',
        tabBarIcon: ({ tintColor }) => (
            <Image
                source={require('../../assets/Images/data.png')}
                style={{ width: 25, height: 25 }}
            />
        ),
        headerTitle: '数据',
        headerTitleStyle: { alignSelf: 'center' }
    };
    state = {
        stationList: []
    }
    componentWillMount() {
        let url = Urls.STATION_LIST + "?size=30";
        fetch(url)
            .then((response) => {
                console.log(response)
                var responsejson = JSON.parse(response._bodyInit);
                this.setState({
                    stationList: responsejson.content.list
                })
            })
            .catch((error) => {
                console.log(error);
            })
    }
    render() {
        const { navigate } = this.props.navigation;
        return (
            <View>
                <WhiteSpace />
                <FlatList
                    data={this.state.stationList}
                    renderItem={({item, index}) => <Item key={index}
                        extra={item.equipmentNum + '个探头'}
                        arrow="horizontal"
                        onClick={() => navigate('DeviceListScreen', { id: item.id, title: item.name })}>{item.name}</Item>}
                    onEndReached={this._onEndReached}
                    keyExtractor={(item, index) => index}
                />
            </View>
        );
    }
    _onEndReached = () => {
        // this.setState((state) => ({
        //   data: state.data.concat(genItemData(100, state.data.length)),
        // }));
        console.log("到底部了")
      };
}

const styles = StyleSheet.create({
    contentContainer: {
        padding: 10
    }
});
